package net.projecteuler.problem3;

/*
 * Largest prime factor
 * ===
 * The prime factors of 13195 are 5, 7, 13 and 29.
 * What is the largest prime factor of the number 600851475143 ?
 */

public class PrimeFactor {
	
	public long largestPrimeFactor(long number) {
		int i = 2;
		long result = 0L;
	
		while(i < number) {
			if(number % i == 0) {
				number = number / i;
				boolean flag = true;
				for(i = 2; i < number; i++) {
					if(number % i == 0) {
						flag = false;
						break;
					}
				}
				if(flag) result = number;
				i = 2;
			}
			i++;
		}
		return result;
	}
	
}
